import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);

let state = {//这里的store用于存储数据，它是一个对象
  cityName:sessionStorage.getItem('cityName')?sessionStorage.getItem('cityName'):'西安'
};
let mutations = {//mutations是用来修改仓库中的数据的
  changeCity(state,cityName){
    //console.log(state.cityName)
    state.cityName = cityName;
    //localStorage.cityName = cityName;
    //sessionStorage.cityName = cityName;
    sessionStorage.setItem('cityName',cityName);
  }
};
export default new Vuex.Store({
  state,
  mutations
})

